// TalkBar.cpp : implementation file
//

#include "stdafx.h"
#include "bookcap.h"
#include "TalkBar.h"
#include "bookcapDlg.h"

// CTalkBar dialog

IMPLEMENT_DYNAMIC(CTalkBar, CDialog)

CTalkBar::CTalkBar(CWnd* pParent /*=NULL*/)
	: CDialog(CTalkBar::IDD, pParent)
{

}

CTalkBar::~CTalkBar()
{
}

void CTalkBar::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_PLAY, m_Play);
	DDX_Control(pDX, IDC_STOP, m_Stop);
}


BEGIN_MESSAGE_MAP(CTalkBar, CDialog)
	ON_BN_CLICKED(IDC_PLAY, &CTalkBar::OnBnClickedPlay)
	ON_BN_CLICKED(IDC_STOP, &CTalkBar::OnBnClickedStop)
END_MESSAGE_MAP()


// CTalkBar message handlers

void CTalkBar::OnBnClickedPlay()
{
	((CbookcapDlg*)GetParent())->speakSelection();
}

void CTalkBar::OnBnClickedStop()
{
	((CbookcapDlg*)GetParent())->stopVoice();
}

BOOL CTalkBar::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_Play.SetIcon(AfxGetApp()->LoadIcon(IDI_PLAY));
	m_Stop.SetIcon(AfxGetApp()->LoadIcon(IDI_STOP));

	return TRUE; 
}

void CTalkBar::OnCancel()
{
	((CbookcapDlg*)GetParent())->ShowTalkBar(0);
}


BOOL CTalkBar::PreTranslateMessage(MSG* pMsg)
{
    if ((pMsg->message == WM_KEYDOWN) || (pMsg->message == WM_KEYUP)) {
        if(pMsg->wParam==VK_ESCAPE)
			return TRUE;
    }	

	return CDialog::PreTranslateMessage(pMsg);
}
